/*
 * Created on 2008-8-1
 *
 * TODO
 */
package jacky.lanlan.song.junitx.v4.conc;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.ThreadPoolExecutor;

/**
 * 线程池工厂，用来创建并发测试用的线程池。
 * @author Jacky.Song
 */
public interface ThreadPoolFactory<T extends ThreadPoolExecutor & ScheduledExecutorService> {

	/**
	 * 默认线程池大小，5个线程。
	 */
	int DEFAULT_SIZE=5;
	
	T createFactory();
	
	/**
	 * 默认工厂，提供CachedThreadPool。
	 */
	ThreadPoolFactory defaultFactory=new ThreadPoolFactory<ScheduledThreadPoolExecutor>() {
		public ScheduledThreadPoolExecutor createFactory() {
			return (ScheduledThreadPoolExecutor) Executors.newScheduledThreadPool(DEFAULT_SIZE);
		}
	};
	
}
